<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
	<meta http-equiv="content-type" content="text/html; charset=UTF-8">
	<meta charset="utf-8">
	<title>工位更换审核 - ${siteName}</title>
	<meta name="description" content="">
	<meta name="author" content="xuzewei">
	<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1, user-scalable=no">
	<link rel="stylesheet" type="text/css" href="css/cloud-admin.css" >
	<link rel="stylesheet" type="text/css" href="css/themes/default.css" id="skin-switcher" >
	<link rel="stylesheet" type="text/css" href="css/responsive.css" >
	<link rel="stylesheet" type="text/css" href="font-awesome/css/font-awesome.min.css">
	<!-- JQUERY UI-->
	<link rel="stylesheet" type="text/css" href="js/jquery-ui-1.10.3.custom/css/custom-theme/jquery-ui-1.10.3.custom.min.css" />
	<!-- DATE RANGE PICKER -->
	<link rel="stylesheet" type="text/css" href="js/bootstrap-daterangepicker/daterangepicker-bs3.css" />
	<!-- JQGRID -->
	<link rel="stylesheet" type="text/css" href="js/jqgrid/css/ui.jqgrid.min.css" />
	<!-- HUBSPOT MESSENGER -->
	<link rel="stylesheet" type="text/css" href="js/hubspot-messenger/css/messenger.min.css" />
	<link rel="stylesheet" type="text/css" href="js/hubspot-messenger/css/messenger-theme-flat.min.css" />
	<link rel="stylesheet" type="text/css" href="css/base.css" />
	<link rel="stylesheet" type="text/css" href="css/main.css" />
	<style type="text/css">
		.leaseimg1{
			background-color: #ffffff;
			}
		.leaseimg2{
			background-color:#708090;
		}
		.leaseimg3{
			background-color:#00e09e;
		}
		.leaseimg4{
			background-color:#4b5cc4;
		}
	</style>
</head>
<body id="app" ng-app="app" ng-controller="ctrl">
	<!-- HEADER -->
	<jsp:include page="include/header.jsp" />
	<!--/HEADER -->
	<!-- PAGE -->
	<section id="page">
		<!-- SIDEBAR -->
		<jsp:include page="include/sidebar.jsp" />
		<!-- /SIDEBAR -->
		<div id="main-content">
			<div class="container">
				<div class="row">
					<div id="content" class="col-lg-12">
						<!-- PAGE HEADER-->
						<div class="row">
							<div class="col-sm-12">
								<div class="page-header">
									<!-- BREADCRUMBS -->
									<ul class="breadcrumb">
										<li>
											<i class="fa fa-home"></i>
											<a href="welcome.jsp">Home</a>
										</li>
									</ul>
									<!-- /BREADCRUMBS -->
									<div class="clearfix">
										<h3 class="content-title pull-left">工位更换审核</h3>
									</div>
									<div class="description"></div>
								</div>
							</div>
						</div>
						<!-- /PAGE HEADER -->
						<div class="box border orange">
							<div class="box-title">
								<h4><i class="fa fa-bars"></i>工位更换审核</h4>
							</div>
							<div class="box-body big">
								<form role="form">
									 <div class="form-group">
									  <label>公司名称</label>
									  <input type="text" class="form-control" ng-model=" entrepreneur.name" readonly='true'>
									</div>
									<div class="form-group">
									  <label>联系人</label>
									  <input type="text" class="form-control" ng-model="entrepreneur.linkman" readonly='true'>
									  <input ng-model="Entrepreneur.entrepreneurId" style="display:none;">
									</div>
									<div class="form-group">
									  <label>联系方式</label>
									  <input type="text" class="form-control" ng-model="entrepreneur.phone" readonly="ture">
									</div>
									<div class="form-group" >
									<div class="form-group" >
										<label >租位图</label>
										<table id="leasetab" class="addr_table" cellpadding="0" cellspacing="0">
									</table>
									</div>
									<div class="form-group" >
									<label style="width: 60px;height: 20px; background-color:#00e09e;"></label>您之前的工位
									<label style="width: 60px;height: 20px; background-color:#708090;"></label>已被占用
									<label style="width: 60px;height: 20px; background-color:#4b5cc4;"></label>调整后的工位
									</div>
									</div>
									<div class="form-group">
									  <label>租用结束时间</label>
									  <input id="startTime" type="text" class="form-control"  value="{{lease.endTime|date:'yyyy-MM-dd'}}" readonly='true'>
									</div>
									<div class="form-group">
									  <label>审核结果</label>
									 </div>
									<div class="form-group">
									 <label class="radio-inline">
									<input name="applyAtatus" type="radio" value=1 ng-model="status" >确定
									</label>
									<label class="radio-inline">
									<input name="applyAtatus" type="radio" value=4 ng-model="status">驳回
									</label>
									</div>
									<div class="form-group">
									  <label >备注</label>
									  <input ng-model="lease.leaseId" style="display:none;">
									  <textarea class="form-control col-md-3" ng-model="changeRemark"  placeholder="说明：选择驳回时，必须输入驳回备注原因"></textarea>
									</div>
									<div id="hide1">
									</div>
									<button type="submit" class="btn btn-danger" ng-click="submit()">提交</button>
								</form>
							</div>
						</div>
						<div class="footer-tools">
							<span class="go-top">
								<i class="fa fa-chevron-up"></i> Top
							</span>
						</div>
					</div><!-- /CONTENT-->
				</div>
			</div>
		</div>
	</section>
	<!--/PAGE -->
	
	<!-- JAVASCRIPTS -->
	<!-- Placed at the end of the document so the pages load faster -->
	<!-- JQUERY -->
	<script src="js/jquery/jquery-2.0.3.min.js"></script>
	<!-- JQUERY UI-->
	<script src="js/jquery-ui-1.10.3.custom/js/jquery-ui-1.10.3.custom.min.js"></script>
	<!-- BOOTSTRAP -->
	<script src="bootstrap-dist/js/bootstrap.min.js"></script>
	<!-- DATE RANGE PICKER -->
	<script src="js/bootstrap-daterangepicker/moment.min.js"></script>
	<script src="js/bootstrap-daterangepicker/daterangepicker.min.js"></script>
	<!-- SLIMSCROLL -->
	<script type="text/javascript" src="js/jQuery-slimScroll-1.3.0/jquery.slimscroll.min.js"></script>
	<script type="text/javascript" src="js/jQuery-slimScroll-1.3.0/slimScrollHorizontal.min.js"></script>
	<!-- BLOCK UI -->
	<script type="text/javascript" src="js/jQuery-BlockUI/jquery.blockUI.min.js"></script>
	<!-- JQGRID -->
	<script type="text/javascript" src="js/jqgrid/js/grid.locale-en.min.js"></script>
	<script type="text/javascript" src="js/jqgrid/js/jquery.jqGrid.min.js"></script>
	<!-- COOKIE -->
	<script type="text/javascript" src="js/jQuery-Cookie/jquery.cookie.min.js"></script>
	<!-- HUBSPOT MESSENGER -->
	<script type="text/javascript" src="js/hubspot-messenger/js/messenger.min.js"></script>
	<script type="text/javascript" src="js/hubspot-messenger/js/messenger-theme-flat.js"></script>
	<script type="text/javascript" src="js/hubspot-messenger/js/messenger-theme-future.js"></script>
	<script src="js/script.js"></script>
	<!-- ANGULAR-LIBRARY -->
	<script src="angular-1.5.0-rc.2/angular.js"></script>
	<!-- CUSTOM SCRIPT -->
	<script src="include/common.js"></script>
	<script>
	var sumRental=0;
	var app = angular.module("app", []);
	app.controller('ctrl', function($scope, $http, $httpParamSerializer, $injector, $window) {
		$scope.lease = {
				"id": "${param.id}"
			}
		//提交
		$scope.submit = function() {
				var reqDate = jQuery.param({
				"status":$scope.status,
				"changeRemark":$scope.changeRemark,
				"leaseId":$scope.lease.id
			});
				
				var reqConfig = { headers: { "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"} };
			$http.post("api/resourecLease/auditChange", reqDate,reqConfig
					).success(function (data) {
				  isErr(data) ? showErrMsg(data) : showMsg(data.response);
			  });
		}; 
		//查询lease对象
		$scope.queryLease = function() {
			var reqDate = jQuery.param({
				"leaseId":$scope.lease.id
			});
			var reqConfig = { headers: { "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"} };
			$http.post(
				"api/resourecLease/queryLease", reqDate,reqConfig
			).success(function(data, status) {
				if (isErr(data)) {
					showErrMsg(data);
					return;
				}
				$scope.lease = data.response;
			}).error(function(data, status) {
				showNetworkErrMsg(data, status);
			});
		};
		
		//查询Entrepreneur对象
		$scope.queryEntrepreneur = function() {
			var reqDate = jQuery.param({
				"leaseId":$scope.lease.id
			});
			var reqConfig = { headers: { "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"} };
			$http.post(
				"api/resourecLease/queryEntrepreneur", reqDate,reqConfig
			).success(function(data, status) {
				if (isErr(data)) {
					showErrMsg(data);
					return;
				}
				$scope.entrepreneur = data.response;
			}).error(function(data, status) {
				showNetworkErrMsg(data, status);
			});
		};
		//生成工位图
		$scope.stationImg=function(arr,arr1){
			var reqDate = jQuery.param({
				"leaseId":$scope.lease.id
			});
			var reqConfig = { headers: { "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"} };
			$http.post(
				"api/resourecLease/seeChangeStation",reqDate,reqConfig
			).success(function(data, status) {
				if (isErr(data)) {
					showErrMsg(data);
					return;
				}
				var	stations=data.response.listSP;
				var req=data.response.listAllS;
				var changeStations=data.response.listSC;
				if(req.length>0){
					var b=parseInt(req[0].totalLines);
					var a=parseInt(req[0].totalRows);
				$('#leasetab').empty();
				for(i=0;i<b;i++){
				$('#leasetab').append("<tr id='tr"+i+"'></tr>");
				for(j=0;j<a;j++){
						var fagle=false;
						var fagle1=false;
						if(stations.length<=0){
							fagle=false;
						}else{
							for(d=0;d<stations.length;d++){
								if(req[(i*a)+j].name==stations[d].name){
									fagle=true;
									break;
								}
							}
						}
						for(d=0;d<changeStations.length;d++){
								if(req[(i*a)+j].name==changeStations[d].name){
									fagle1=true;
									break;
								}
							}
						if(req[(i*a)+j].state!=0){
							if(fagle){
								var f="s"+i+j;
								var val=name+i+j+","+i+","+j;
								$("#tr"+i).append("<td id='td"+f+"'>"+req[(i*a)+j].name+"</td>");
								$("#td"+f).css("background","#00e09e");
							}else
								if(fagle1){
									console.log(fagle1);
										var f="s"+i+j;
										var val=name+i+j+","+i+","+j;
										$("#tr"+i).append("<td id='td"+f+"'>"+req[(i*a)+j].name+"</td>");
										$("#td"+f).css("background","#4b5cc4");
									
								}else{
									var f="s"+i+j;
									var val=name+i+j+","+i+","+j;
									$("#tr"+i).append("<td id='td"+f+"'>"+req[(i*a)+j].name+"</td>");
									$("#td"+f).css("background","#708090");
								}
								}else{	
									var f="s"+i+j;
									var val=name+i+j+","+i+","+j;
									$("#tr"+i).append("<td id='td"+f+"'>"+req[(i*a)+j].name+"</td>");
								}
							}
						}
					}
			}).error(function(data, status) {
				showNetworkErrMsg(data, status);
			});
		}
		
		$scope.logout = function() {
			logout($window.zone);
		};
	});
	</script>
	<script>
	jQuery(document).ready(function() {
		App.init();
		jQuery('#nav_resource-manage').click();
		setTimeout(function () { 
			var scope = angular.element('#app').scope();
			scope.stationImg();
			scope.queryLease();
			scope.queryEntrepreneur();
		}, 500);
	});
	</script>
	<!-- /JAVASCRIPTS -->
</body>
</html>